package arg

import (
	"db2s/global"
)

type structLevel struct {
	AlterObject       []string                     `json:"alterObject"`
	AlterSubObject    map[string][]string          `json:"alterSubObject"`
	MapList           map[string]map[string]string `json:"mapList"`
	FixRule           map[string]map[string]string `json:"alterRule"`
	AlterMethod       string                       `json:"alterMethod"`
	SqlMode           bool                         `json:"sqlMode"`
	BreakPoint        bool                         `json:"breakpoint"`
	Drop              bool                         `json:"drop"`
	SqlLogBin         bool                         `json:"logBin"`
	Case              bool                         `json:"case"`
	WriteParameterOpt bool                         `json:"paramOpt"`
}



func structParameterCheck(s *SecondaryLevel) (err error) {
	var (
		structCheckObjectOptionalMap map[string]any
		structFixRuleOptionMap       map[string]any
	)
	if structCheckObjectOptionalMap, err = global.StructSubJsonNameToMap(structCheckObjectOptionalValue{}); err != nil {
		return
	}
	for k := range s.RulesV.Struct.SCheckMod {
		if !parameterOptions(structCheckObjectOptionalMap, k) {
			delete(s.RulesV.Struct.SCheckMod, k)
		}
	}
	if structFixRuleOptionMap, err = global.StructSubJsonNameToMap(structFixRuleOptionValue{}); err != nil {
		return
	}
	if !parameterOptions(structFixRuleOptionMap, s.RulesV.Struct.AlterMethod) {
		s.RulesV.Struct.AlterMethod = "many"
	}
	s.RulesV.Struct.ErrorSqlFile = "execSqlErr"
	return
}
